
import { DataTypes } from 'sequelize';
import sequelize from '../config/db.js';

const ArticleView = sequelize.define('ArticleView', {
  ip: {
    type: DataTypes.STRING(128), // 支持 IPv6 地址
    allowNull: false
  },
  user_agent: DataTypes.STRING(512),
  article_id: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false
  },
  user_id: {
    type: DataTypes.UUID, // 支持 UUID
    allowNull: true
  }
}, {
  timestamps: true,
  updatedAt: false,
  createdAt: 'created_at'

});

export default ArticleView;